Compiling Java to PLT Scheme
نویسندگان
چکیده
Our experimental compiler translates Java to PLT Scheme; it enables the use of Java libraries within Scheme programs, and it makes our Scheme programming tools available when programming with Java. With our system, a programmer can extend and use classes from either language, and Java programmers can employ other Scheme data by placing it in a class using the Java native interface. PLT Scheme’s class-system, implemented with macros, provides a natural target for Java classes, which facilitates interoperability between the two languages, and PLT Scheme’s modulemaintains Java security restrictions in Scheme programs. Additionally, module’s restrictions provide a deeper understanding of a Java compilation unit and make Java’s implicit compilation units explicit. 1 Why Compile Java to Scheme? Scheme implementations that compile to Java (or JVM bytecode) benefit from the extensive infrastructure available for Java programs, including optimizing just-in-time compilers, JVM debugging tools, and an impressive roster of Java-based libraries. For PLT Scheme, we have inverted the equation, compiling Java to Scheme. We thus obtain a Java implementation with access to PLT Scheme’s libraries and facilities—especially the DrScheme environment and its teaching modes [5], which is the primary motivation for our effort [9]. By compiling Java to Scheme, we also gain access to the many libraries implemented in Java, as long as we can bridge the gap between Java and Scheme. In many ways, the translation is the same for Java-to-Scheme compilation as it is for Scheme-to-Java, but the trade-offs are somewhat different. In particular, libraries that contain native calls are no problem for Scheme-to-Java compilation, but Java-to-Scheme must provide special support for native methods. In contrast, a Scheme compilation model with expressive macros accommodates Java code more easily than Java’s model of Permission to make digital or hard copies, to republish, to post on servers or to redistribute to lists all or part of this work is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To otherwise copy or redistribute requires prior specific permission. Fifth Workshop on Scheme and Functional Programming. September 22, 2004, Snowbird, Utah, USA. Copyright 2004 Kathryn E Gray and Matthew Flatt. compilation accommodates Scheme. Our Java-to-Scheme compiler remains a work in progress. Even so, we have gained experience that may be useful to future implementors of Java-to-Scheme compilers. In the long run, we expect that many useful Java libraries will fit into our implementation, as PLT Scheme provides a significant set of libraries of its own. For example, we expect that the subset of AWT used by Swing can be mapped onto PLT Scheme’s GUI primitives, thus enabling Swing-based applications to run in PLT Scheme. In other words, we believe that many Java libraries can be made to run by re-implementing certain “native” Java methods in PLT’s native language, Scheme. In this report, we describe • a strategy for compiling Java classes to PLT Scheme, which exploits a macro-implemented extension of Scheme for object-oriented programming; • the interaction of the strategy with PLT Scheme’s module system; • how we define the translation of run-time values between Java and Scheme; and • open problems that we have not yet addressed. Before introducing our compilation strategy, we begin with a description of two libraries that we would like to embed in Scheme, and the strategy of doing so. One is relatively easy to support, and the other is more difficult.
منابع مشابه
Links: Web Programming Without Tiers
Links is a programming language for web applications that generates code for all three tiers of a web application from a single source, compiling into JavaScript to run on the client and into SQL to run on the database. Links supports rich clients running in what has been dubbed ‘Ajax’ style, and supports concurrent processes with statically-typed message passing. Links is scalable in the sense...
متن کاملKawa: Compiling Scheme to Java
Kawa is a set of Java classes useful for implementing dynamic languages, such as those in the Lisp family. Kawa is also an implementation of near-R5RS Scheme using these classes, and which compiles Scheme to the bytecode instructions of the Java Virtual Machine. This paper discusses the various issues involved in implementing Scheme using an abstract machine designed for a very different langua...
متن کاملCompiling Constraint Handling Rules to Java: A Reconstruction
In this report, we provide a detailed description of the compilation scheme the K.U.Leuven JCHR system uses to compile CHR to efficient Java code. We start from a relatively straightforward adaptation of the traditional CHR compilation scheme for Prolog, and gradually add all its basic optimizations. Next, we show why this compilation scheme is not suited for compilation to an imperative host l...
متن کاملMixing Lisps in Kawa
Kawa started as a Scheme implementation written in Java, based on compiling Scheme forms to Java byte-codes. It has developed into a powerful Scheme dialect whose strengths include speed and easy access to Java classes. It is Free Software that some companies depend on. The Kawa compiler and run-time environment have been generalized to implement other languages besides Scheme, both in the Lisp...
متن کاملImplementing PLT Webserver API on top of Java Servlets
This paper deals with the implementation of a subset of the PLT webserver core API for Java Servlets. The core idea is to use thread suspension and resumption to model a limited form of continuations. Since this implementation is layered on top of the Java servlet API, it would work for any multi threaded webserver which supports the Java Servlets API.
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 2004